﻿/*
   @Description:客源公共js
   @Author:
   @Date:2014-02-12  
 */

var CustomerCommon = {};

$(function () {
    //页面初始化时去掉重复绑定能容Start
    $("#btnCustomerSms,#customerCheckCustomer,#customerEditCustomer,#customerTransferCustomer,#publicCustomerTransferCustomer,#customerStatusModify,#publicCustomerStatusModify,#customerSetModify,#publicCusCheckCustomer,#publicDelCustomer").addClass("edit-btn-gray").removeClass("btn-blue");

    $('.setCustom').css('display', 'none');
    $('#inquiryStatusKeyIdAll').css('display', 'none');
    $('#btnSubmitIsVip').unbind('click');

    //页面初始化时去掉重复绑定能容End


    //查看客户操作
    $('#customerCheckCustomer').unbind('click');
    $('#customerCheckCustomer').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList');
        if (objCheck == false) {
            return false;
        }
        $('#customerCheckCustomer').attr('href', '/customer/inquiry-details?keyId=' + objCheck.attr('keyId'));
    });

    //公客池查看客户操作
    $('#publicCusCheckCustomer').unbind('click');
    $('#publicCusCheckCustomer').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList');
        if (objCheck == false) {
            return false;
        }
        $('#publicCusCheckCustomer').attr('href', '/customer/inquiry-details?keyId=' + objCheck.attr('keyId'));
    });

    //编辑客户操作
    $('#customerEditCustomer').unbind('click');
    $('#customerEditCustomer').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList');
        if (objCheck == false) {
            return false;
        }
        if (!customerRight.CheckRightRol(objCheck, "Customer.Inquiry.Modify", true)) {
            return false;
        }
        $('#customerEditCustomer').attr('href', '/customer/inquiry-edit?keyId=' + objCheck.attr('keyId') + '&CustomerName=' + encodeURI(objCheck.attr('customername')));
    });

    //发短信操作
    $('#btnCustomerSms').unbind('click');
    $('#btnCustomerSms').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true);
        if (objCheck == false) {
            return false;
        }
        var selectKeyId = '';
        objCheck.each(function () {
            selectKeyId += $(this).attr('keyid') + ',';
        });
        selectKeyId = selectKeyId.substr(0, selectKeyId.length - 1);

        //弹出短信
        var reqData = {
            'selectKeyIds': selectKeyId
        };
        $.AjaxAgency('/customer/inquiry-send-message', reqData, function (data) {
            $.dialog({
                id: "dialogCommonSms",
                lock: true,
                content: data
            });
        });

    });

    //转客操作 全部客源
    $('#customerTransferCustomer').unbind('click');
    $('#customerTransferCustomer').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true);
        if (objCheck == false) {
            return false;
        }
        $.dialog({
            id: "CustomertransferCustom",
            title: "转客",
            lock: true,
            content: $("#transferCustom").html()
        });
        TransferCustomer.inte();
        agencyVerify.notNullInput(null, ".aui_content input[isnull=1]", false, "change");
        agencyVerify.notdefaultSelect(null, ".aui_content #selPublicDepartment", -1, "请选择公盘帐号", false);
        TransferCustomer.getCustomerIds = function () {
            var keyIds = new Array();
            var index = 0;
            objCheck.each(function () {
                keyIds[index] = $(this).attr('KeyId');
                index++;
            });

            return keyIds;
        };
        TransferCustomer.successed = function () {
            $.OKDialogAgency('<div class="tc">转客成功！</div>', '提示', function () {
                $.artDialog({ id: 'CustomertransferCustom' }).close();
                //获取当前页用于刷新本页
                var pageIndex = $("#hidlispage").val();
                if (pageIndex != null && pageIndex != "") {
                    $("#hidPage").val($("#hidlispage").val());
                }
                $('#searchForm').submit();
                $("#hidPage").val("");
            });
        };
    });
    //转客操作 公客池
    $('#publicCustomerTransferCustomer').unbind('click');
    $('#publicCustomerTransferCustomer').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true);
        if (objCheck == false) {
            return false;
        }
        $.dialog({
            id: "CustomertransferCustom",
            title: "转客",
            lock: true,
            content: $("#transferCustom").html()
        });
        TransferCustomer.inte();
        agencyVerify.notNullInput(null, ".aui_content input[isnull=1]", false, "change");
        agencyVerify.notdefaultSelect(null, ".aui_content #selPublicDepartment", -1, "请选择公盘帐号", false);
        TransferCustomer.getCustomerIds = function () {
            var keyIds = new Array();
            var index = 0;
            objCheck.each(function () {
                keyIds[index] = $(this).attr('KeyId');
                index++;
            });

            return keyIds;
        };
        TransferCustomer.successed = function () {
            $.OKDialogAgency('<div class="tc">转客成功！</div>', '提示', function () {
                $.artDialog({ id: 'CustomertransferCustom' }).close();
                //获取当前页用于刷新本页(深圳需求不刷新页面)
                //var pageIndex = $("#hidlispage").val();
                //if (pageIndex != null && pageIndex != "") {
                //    $("#hidPage").val($("#hidlispage").val());
                //}
                //$('#searchForm').submit();
                //$("#hidPage").val("");
            });
        };
    });

    //状态更改操作 全部客源
    $('#customerStatusModify').unbind('click');
    $('#customerStatusModify').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true);
        if (objCheck == false) {
            return false;
        }
        if (!$(this).attr("publiccustomer") && !customerRight.CheckRightRol(objCheck, "Customer.Inquiry.Modify", true)) {
            return false;
        }
        var currentClass = $('#customerStatusModify i').attr("class");
        if ($('#customerSetModify i').attr('class') != 'icon-statusModify') {
            $('#customerSetModify i').attr('class', 'icon-statusModify');
            $('.setCustom').css('display', 'none');
        }

        if (currentClass == 'icon-statusModify') {
            $('#customerStatusModify i').attr('class', 'icon-statusModify-on');
            $(".statusModify").show();
        } else {
            $('#customerStatusModify i').attr('class', 'icon-statusModify');
            $(".statusModify").hide();
        }
        function tempFunc2() {
            $('#customerStatusModify i').attr('class', 'icon-statusModify');
        }
        CustomerCommon.showAndHide('#customerStatusModify', 'inquiryStatusKeyIdAll', tempFunc2, 'iStatusModify');

        var keyIds = new Array();
        var index = 0;
        objCheck.each(function () {
            keyIds[index] = $(this).attr('KeyId');
            index++;
        });
        $('#btnChangeCustomerStatu').unbind('click');
        $('#btnChangeCustomerStatu').click(function () {
            $('#customerStatusModify i').attr('class', 'icon-statusModify');
            $(this).attr('disabled', 'disabled');
            var targetStatusKeyId = $("#inquiryStatusKeyIdAll input[type=radio]:checked").val();
            if (!!targetStatusKeyId) {
                $.ajax({
                    url: '/Customer/inquiry-status-change-ajax',
                    type: 'post',
                    data: { 'targetStatusKeyId': targetStatusKeyId, 'keyIds': keyIds.join(',') },
                    success: function (data) {
                        if (data == 'ok') {
                            $('#btnChangeCustomerStatu').removeAttr('disabled');
                            $.OKDialogAgency('<div class="tc">设置成功！</div>', '提示', function () {
                                $("#inquiryStatusKeyIdAll").hide();
                                //获取当前页用于刷新本页
                                var pageIndex = $("#hidlispage").val();
                                if (pageIndex != null && pageIndex != "") {
                                    $("#hidPage").val($("#hidlispage").val());
                                }
                                $('#searchForm').submit();
                                $("#hidPage").val("");
                            });
                        } else {
                            $('#btnChangeCustomerStatu').removeAttr('disabled');
                            $.OKDialogAgency('<div class="tc">' + data + '</div>');
                        }
                    }
                });
            }
            else {
                $.OKDialogAgency('<div class="tc">请选择要修改的状态！</div>');
                $('#btnChangeCustomerStatu').removeAttr('disabled');
            }
        });
    });

    //状态更改操作 公客池
    $('#publicCustomerStatusModify').unbind('click');
    $('#publicCustomerStatusModify').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true);
        if (objCheck == false) {
            return false;
        }
        if (!$(this).attr("publiccustomer") && !customerRight.CheckRightRol(objCheck, "Customer.Inquiry.Modify", true)) {
            return false;
        }
        var currentClass = $('#publicCustomerStatusModify i').attr("class");
        if ($('#customerSetModify i').attr('class') != 'icon-statusModify') {
            $('#customerSetModify i').attr('class', 'icon-statusModify');
            $('.setCustom').css('display', 'none');
        }

        if (currentClass == 'icon-statusModify') {
            $('#publicCustomerStatusModify i').attr('class', 'icon-statusModify-on');
            $(".statusModify").show();
        } else {
            $('#publicCustomerStatusModify i').attr('class', 'icon-statusModify');
            $(".statusModify").hide();
        }
        function tempFunc2() {
            $('#publicCustomerStatusModify i').attr('class', 'icon-statusModify');
        }
        CustomerCommon.showAndHide('#publicCustomerStatusModify', 'inquiryStatusKeyIdAll', tempFunc2, 'iStatusModify');

        var keyIds = new Array();
        var index = 0;
        objCheck.each(function () {
            keyIds[index] = $(this).attr('KeyId');
            index++;
        });
        $('#btnChangeCustomerStatu').unbind('click');
        $('#btnChangeCustomerStatu').click(function () {
            $('#publicCustomerStatusModify i').attr('class', 'icon-statusModify');
            $(this).attr('disabled', 'disabled');
            var targetStatusKeyId = $("#inquiryStatusKeyIdAll input[type=radio]:checked").val();
            if (!!targetStatusKeyId) {
                $.ajax({
                    url: '/Customer/inquiry-status-change-ajax',
                    type: 'post',
                    data: { 'targetStatusKeyId': targetStatusKeyId, 'keyIds': keyIds.join(',') },
                    success: function (data) {
                        if (data == 'ok') {
                            $('#btnChangeCustomerStatu').removeAttr('disabled');
                            $.OKDialogAgency('<div class="tc">设置成功！</div>', '提示', function () {
                                $("#inquiryStatusKeyIdAll").hide();
                                //获取当前页用于刷新本页（深圳需求不刷新页面）
                                //var pageIndex = $("#hidlispage").val();
                                //if (pageIndex != null && pageIndex != "") {
                                //    $("#hidPage").val($("#hidlispage").val());
                                //}
                                //$('#searchForm').submit();
                                //$("#hidPage").val("");
                            });
                        } else {
                            $('#btnChangeCustomerStatu').removeAttr('disabled');
                            $.OKDialogAgency('<div class="tc">' + data + '</div>');
                        }
                    }
                });
            }
            else {
                $.OKDialogAgency('<div class="tc">请选择要修改的状态！</div>');
                $('#btnChangeCustomerStatu').removeAttr('disabled');
            }
        });
    });

    //设置客户操作
    $('#customerSetModify').unbind('click');
    $('#customerSetModify').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true, true);
        if (objCheck == false) {
            return false;
        }

        var currentClass = $('#customerSetModify i').attr("class");
        if ($('#customerStatusModify i').attr('class') != 'icon-statusModify') {
            $('#customerStatusModify i').attr('class', 'icon-statusModify');
            $('#inquiryStatusKeyIdAll').css('display', 'none');
        }

        if (currentClass == 'icon-statusModify') {
            $('#customerSetModify i').attr('class', 'icon-statusModify-on');
            $(".setCustom").show();
        } else {
            $('#customerSetModify i').attr('class', 'icon-statusModify');
            $(".setCustom").hide();
        }
        function tempFunc() {
            $('#customerSetModify i').attr('class', 'icon-statusModify');
        }
        CustomerCommon.showAndHide('#customerSetModify', 'ulSetCustom', tempFunc, 'iSetModify');

        $('#btnSubmitIsVip').unbind('click');
        $('#btnSubmitIsVip').click(function () {
            $('#customerSetModify i').attr('class', 'icon-statusModify');
            var isVipresult = $(".setCustom input[type=radio]:checked").val();
            var keyIds = new Array();
            var index = 0;
            if (isVipresult == "true") {
                if ($('#gdIndexCustomerList input[type=checkbox][isVip]:checked').length > 0) {
                    $.OKDialogAgency('<div class="tc">存在客源已经是VIP，请不要重复设置！</div>');
                    return;
                }
            }
            $('#gdIndexCustomerList input[type=checkbox]:checked').each(function () {
                keyIds[index] = $(this).attr('KeyId');
                index++;
            });
            if (keyIds.length == 0) {
                $.OKDialogAgency('<div class="tc">请选择客户！</div>');
                return;
            }
            $(this).attr('disabled', 'disabled');
            $.ajax({
                url: '/Customer/inquiry-vip-batch-cancel-ajax',
                type: 'post',
                data: { 'isVip': isVipresult, 'keyIds': keyIds.join(',') },
                success: function (data) {
                    if (data == 'ok') {
                        $('#btnSubmitIsVip').removeAttr('disabled');
                        $.OKDialogAgency('<div class="tc">设置成功！</div>', '提示', function () {
                            $("#ulSetCustom").hide();
                            $('#searchForm').submit();
                        });
                    } else {
                        $('#btnSubmitIsVip').removeAttr('disabled');
                        $.OKDialogAgency('<div class="tc">' + data + '</div>');
                    }
                }
            });

        });

    });

    //常用列设置
    $('#btnCustomerColumnSettings').unbind('click');
    $('#btnCustomerColumnSettings').click(function () {
        $.AjaxAgency('/Customer/inquiry-dynamic-line', null, function (data) {
            $.dialog({
                id: "dialogColumnSettings",
                title: "常用列设置",
                width: 400,
                lock: true,
                content: data
            });
        });
    });

    //删除客户操作
    $('#DelCustomer').unbind('click');
    $('#DelCustomer').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true);
        if (objCheck == false) {
            return false;
        }

        var selectKeyId = '';
        if (!customerRight.CheckRightRols(objCheck, "Customer.Inquiry.Delete", true)) {
            return false;
        }
        //if (!confirm('您确定要删除吗？')) {
        //    return false;
        //}
        $.OKCancelDialogAgency('<div class="tc">您确定要删除客户吗？</div>', '删除客户', true, function () {
            objCheck.each(function () {
                selectKeyId += $(this).attr('keyid') + ',';
            });
            selectKeyId = selectKeyId.substr(0, selectKeyId.length - 1);
            var reqData = {
                'keyIds': selectKeyId
            };
            $.AjaxAgency('/customer/inquiry-batch-remove-ajax', reqData, function (data) {
                if (data == 'ok') {
                    $.artDialog({
                        id: "artDialogBatchRemoveInquiry",
                        time: 1,
                        content: '<div class="tc">删除成功！</div>'
                    });
                    $('#searchForm').submit();
                } else {
                    $.artDialog({
                        id: "artDialogBatchRemoveInquiry",
                        lock: true,
                        content: data
                    });
                }
            });
        });
    });
    $('#publicDelCustomer').unbind('click');
    $('#publicDelCustomer').click(function () {
        var objCheck = CustomerCommon.checkCustomerInfo('gdIndexCustomerList', true);
        if (objCheck == false) {
            return false;
        }
        //if (!confirm('您确定要删除吗？')) {
        //    return false;
        //}
        $.OKCancelDialogAgency('<div class="tc">您确定要删除客户吗？</div>', '删除客户', true, function () {
            var selectKeyId = '';
            objCheck.each(function () {
                selectKeyId += $(this).attr('keyid') + ',';
            });
            selectKeyId = selectKeyId.substr(0, selectKeyId.length - 1);
            var reqData = {
                'keyIds': selectKeyId
            };
            $.AjaxAgency('/customer/inquiry-batch-remove-ajax', reqData, function (data) {
                if (data == 'ok') {
                    $.artDialog({
                        id: "artDialogBatchRemoveInquiry",
                        time: 1,
                        content: '<div class="tc">删除成功！</div>'
                    });
                    //获取当前页用于刷新本页(深圳需求不刷新页面)
                    //var pageIndex = $("#hidlispage").val();
                    //if (pageIndex != null && pageIndex != "") {
                    //    $("#hidPage").val($("#hidlispage").val());
                    //}
                    //$('#searchForm').submit();
                    //$("#hidPage").val("");
                } else {
                    $.artDialog({
                        id: "artDialogBatchRemoveInquiry",
                        lock: true,
                        content: data
                    });
                }
            });
        });
    });

    //公客池中跟进按钮
    $(".open-follow").unbind('click');
    $(".open-follow").bind("click", function () {
        var currentElement = $(this);
        var keyId = currentElement.attr('keyid');
        var type = currentElement.attr('data-type');
        var reqData = {
            'customerKeyId': keyId,
            'customerType':type
        };
        $.AjaxAgency("/customer/public-inquiry-page-follow", reqData, function (data) {
            if (data.indexOf('pageDiscription="我是错误页"') > -1) {
                $.OKDialogAgency('<div class="tc">请求失败！</div>');
            } else {
                $.dialog({
                    id: "dialogOpenFollow",
                    title: "跟进内容",
                    lock: true,
                    content: data
                });
                $.inputStatistics2($("div .aui_content #txtContent"));
                $("#createFollow").click(function () {
                    $("#createFollow").attr("disabled", "disabled");
                    var tempInquiryFollowType = '';
                    $('#divInquiryFollowTypes input[type=radio]:checked').each(function () {
                        tempInquiryFollowType = $(this).val();
                        if ($(this).attr('itemcode') == '200') {
                            $('#txtContent').blur();
                        }
                    });

                    if ($.trim($("#txtContent").val()) == "") {
                        $("#txtContent").parent().find(".wrong").show();
                        $('#txtContent').focus();
                        $("#createFollow").removeAttr("disabled");
                        return false;
                    }

                    if ($('#txtContent + span[class=wrong]').length > 0) {
                        return false;
                    }
                    var reqData = {
                        'InquiryKeyId': keyId,
                        'FollowTypeKeyId': tempInquiryFollowType,
                        'Content': $('#txtContent').val(),
                        'isRetrunVal': 'true'
                    };
                    $.AjaxAgency('/customer/inquiry-other-follow-add-ajax', reqData, function (data) {
                        if (data == "ok") {
                            $.dialog({
                                id: "dialogAddOtherFollow",
                                time: 1,
                                content: '<div class="tc"></div>提交成功！</div>'
                            });
                            art.dialog.get('dialogOpenFollow').close();
                        } else {
                            $.OKDialogAgency('<div class="tc">' + data + '</div>');
                        }
                        $("#createFollow").removeAttr("disabled");
                        currentElement.removeClass("open-follow").addClass("open-follow-no");
                    });
                });
            }
        });

    });
    
    //全选操作
    $("#checkedAll").unbind('click');
    $("#checkedAll").bind("click", function () {
        if (this.checked) {
            $("#gdIndexCustomerList input[type=checkbox]").attr("checked", true);
            $("#customerEditCustomer").addClass("edit-btn-gray").removeClass("btn-blue");
            $("#customerTransferCustomer,#customerStatusModify,#customerSetModify,#DelCustomer,#btnCustomerSms").addClass("btn-blue").removeClass("edit-btn-gray");
        } else {
            $("#gdIndexCustomerList input[type=checkbox]").attr("checked", false);
            $("#customerEditCustomer,#customerTransferCustomer,#customerStatusModify,#customerSetModify,#DelCustomer,#btnCustomerSms").addClass("edit-btn-gray").removeClass("btn-blue");
        }
    });
});
//点击空白处隐藏
CustomerCommon.showAndHide = function (selector, id, func, id2) {
    $(document).unbind("click");
    $(document).bind("click", function (e) {
        var divpanel = $("#" + id);
        var tempoint = divpanel.offset();
        if (e.pageX > (tempoint.left + divpanel.width()) || e.pageX < tempoint.left || e.pageY > (tempoint.top + divpanel.height()) || e.pageY < tempoint.top) {
            if (id2) {
                if (e.target != $(selector)[0] && e.target != $('#' + id2)) {
                    divpanel.hide();
                    if (func) {
                        func();
                    }
                    $(document).unbind("click");
                }
            } else {
                if (e.target != $(selector)[0]) {
                    divpanel.hide();
                    if (func) {
                        func();
                    }
                    $(document).unbind("click");
                }
            }

        }
    });
};


//检测客源是否被选中,isMultiple是否可以多选
CustomerCommon.checkCustomerInfo = function (gdListId, isMultiple, isMyself) {
    var objCheck = $('#' + gdListId + ' input[type=checkbox]:checked');
    if (objCheck.length == 0) {
        $.OKDialogAgency('<div class="tc">请选择客源信息！</div>');
        return false;
    } else if (objCheck.length > 1) {
        if (!isMultiple) {
            $.OKDialogAgency('<div class="tc">客源只能选择一条！</div>');
            return false;
        }

    }
    //var tempResult = true;
    //if (isMyself) {
    //    for (var i = 0; i < objCheck.length; i++) {
    //        if (!$(objCheck[i]).attr('isMyInquiry')) {
    //            tempResult = false;
    //            break;
    //        }
    //    }
    //}
    //if (!tempResult) {
    //    $.OKDialogAgency('<div class="tc">你不能设置别人的客户为VIP！</div>');
    //    return false;
    //}
    return objCheck;
}

CustomerCommon.tableCheckBoxBind = function () {
    //工具栏按钮状态处理
    $("#gdIndexCustomerList input[type=checkbox]").removeAttr("checked");
    $("#customerCheckCustomer,#btnCustomerSms,#customerEditCustomer,#customerTransferCustomer,#publicCustomerTransferCustomer,#customerStatusModify,#publicCustomerStatusModify,#publicCusCheckCustomer,#customerSetModify,#publicDelCustomer,#DelCustomer").addClass("edit-btn-gray").removeClass("btn-blue");
    $("#gdIndexCustomerList input[type=checkbox]").bind("click", function (e) {
        if ($(this).attr("checked") == "checked") {
            $(this).parents(".tbody").css("background-color", "#f6f6f6");
            $(this).parents(".tbody").find(".td-div").css("border-color", "#efc75e");
            $(this).parents(".tbody").find(".tbody-tit span,.tbody-tit a,.tbody-tit em,.inquiry-status").css("color", "#e2574c");
            $(this).parents(".tbody").find(".icon-vip").css("color", "#e2574c");

            $(this).parents(".tbody").hover(function () {
                $(this).css("background-color", "#f6f6f6");
                $(this).find(".td-div").css("border-color", "#efc75e");
            });
        } else {
            $(this).parents(".tbody").css("background-color", "");
            $(this).parents(".tbody").find(".td-div").css("border-color", "#eaeaea");
            $(this).parents(".tbody").find(".tbody-tit span,.inquiry-status").css("color", "#000");
            $(this).parents(".tbody").find(".tbody-tit a").css("color", "#1f73f0");
            $(this).parents(".tbody").find(".tbody-tit em").css("color", "#a0a0a0");
            $(this).parents(".tbody").find(".icon-vip").css("color", "#ec9700");

            $(this).parents(".tbody").hover(function () {
                $(this).css("background-color", "#f6f6f6");
                $(this).find(".td-div").css("border-color", "#cbcbcb");
            }, function () {
                $(this).css("background-color", "");
                $(this).find(".td-div").css("border-color", "#eaeaea");
            });
        }

        var tempGds = $('#gdIndexCustomerList input[type=checkbox]:checked');
        var checkedCount = tempGds.length;
        var tempValue = true;
        if (checkedCount == 1) {
            $("#customerCheckCustomer,#btnCustomerSms,#customerEditCustomer,#customerTransferCustomer,#publicCustomerTransferCustomer,#customerStatusModify,#publicCustomerStatusModify,#publicCusCheckCustomer,#publicDelCustomer,#DelCustomer").addClass("btn-blue").removeClass("edit-btn-gray");
            //for (var i = 0; i < tempGds.length; i++) {
            //    if (!$(tempGds[i]).attr('isMyInquiry')) {
            //        $("#customerSetModify").addClass("edit-btn-gray").removeClass("btn-blue");
            //        tempValue = false;
            //        break;
            //    }
            //}
            //if (tempValue) {
            //    $("#customerSetModify").addClass("btn-blue").removeClass("edit-btn-gray");
            //}
            $("#customerSetModify").addClass("btn-blue").removeClass("edit-btn-gray");
        } else {
            $("#customerCheckCustomer,#customerEditCustomer,#publicCusCheckCustomer").addClass("edit-btn-gray").removeClass("btn-blue");
            $("#btnCustomerSms,#customerStatusModify,#publicCustomerStatusModify,#customerTransferCustomer,#publicCustomerTransferCustomer,#publicDelCustomer,#DelCustomer").addClass("btn-blue").removeClass("edit-btn-gray");
            //for (var i = 0; i < tempGds.length; i++) {
            //    if (!$(tempGds[i]).attr('isMyInquiry')) {
            //        $("#customerSetModify").addClass("edit-btn-gray").removeClass("btn-blue");
            //        tempValue = false;
            //        break;
            //    }
            //}
            //if (tempValue) {
            //    $("#customerSetModify").addClass("btn-blue").removeClass("edit-btn-gray");
            //}
            $("#customerSetModify").addClass("btn-blue").removeClass("edit-btn-gray");
        }
        if (checkedCount < 1) {
            $("#btnCustomerSms,#customerCheckCustomer,#customerEditCustomer,#customerTransferCustomer,#publicCustomerTransferCustomer,#customerStatusModify,#publicCustomerStatusModify,#customerSetModify,#publicCusCheckCustomer,#publicDelCustomer,#DelCustomer").addClass("edit-btn-gray").removeClass("btn-blue");
            $('#customerSetModify i').attr('class', 'icon-statusModify');
            $('.setCustom').css('display', 'none');
            $('#customerStatusModify i').attr('class', 'icon-statusModify');
            $('#publicCustomerStatusModify i').attr('class', 'icon-statusModify');
            $('#inquiryStatusKeyIdAll').css('display', 'none');
        }
    });
}

CustomerCommon.OnSuccess = function () {
    other.hideLoaderMask();
    $("#propertyboolTag :checkbox").each(function () {
        $(this).removeAttr("disabled");
    });

    var tempCount = $("#spanUsedQuota").attr("leavequota");
    if (tempCount > 0) {
        if ($("#btnSubmitSesrch").attr("isSubmitValue") == "true") {
            $("#btnSaveSearchCondition").css("display", "none");
            if ($("#divJsonValue").html()) {
                if ($("#divJsonValue").html().length > 0) {
                    $("#btnSaveSearchCondition").css("display", "");
                    $("#divJson").html($("#divJsonValue").html());
                }
            }
        }
    }

    var inquiryCategory = $("#inquiryCategory").val();
    if (inquiryCategory == 3) {
        $("#transferCustomerSpan").css('display', '');
    } else {
        $("#transferCustomerSpan").css('display', 'none');
    }
    setPageEndTime();
};

CustomerCommon.beginSearch = function () {
    other.showLoaderMask();
    $("#propertyboolTag :checkbox").each(function () {
        $(this).attr("disabled", "disabled");
    });
    if ("undefined" != typeof ajaxpageronbegin) {
        ajaxpageronbegin();
    }
};

CustomerCommon.OnFailure = function () {
    other.hideLoaderMask();
    $("#propertyboolTag :checkbox").each(function () {
        $(this).removeAttr("disabled");
    });
    other.hideLoaderMask();
};